package org.mch.start;

import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Properties;

import org.mch.comm.exec.MsgException;
import org.mch.main.MCHFrame;

public class MEnv {

	private static final Properties conf;
	static {
		URL fileurl = MEnv.class.getResource("/resource/config/mchutils.properties");

		conf = new Properties();
		try {
			conf.load(new FileInputStream(new File(fileurl.getFile())));
		} catch (Exception e) {
			throw new MsgException("加载 系统配置文件 mchutils.properties失败！");
		}
	}

	public static String get(String key) {
		return conf.getProperty(key);
	}

	public static boolean isDev() {
		String mchdev = conf.getProperty("mchdev");

		if (mchdev.equalsIgnoreCase("y") || mchdev.equalsIgnoreCase("yes") || mchdev.equalsIgnoreCase("true")) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 状态栏消息；
	 * 
	 * @param msg
	 */
	public static void statusMsg(String msg) {
		MCHFrame.getFrame().getLabelCenter().setText(msg);
	}

	public static void clearStatusMsg() {
		MCHFrame.getFrame().getLabelCenter().setText("");
	}
}
